package cn.edu.suda.schoolBus.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.suda.schoolBus.bean.Driver;
import cn.edu.suda.schoolBus.service.DriverService;
import cn.edu.suda.schoolBus.util.ResultUtil;

@Controller
public class DriverController {

	@Autowired
	private DriverService driverService;

	@RequestMapping("/addDriver")
	@ResponseBody
	public Map<String, Boolean> addDriver(Driver driver) {
		return ResultUtil.getResult(driverService.addDriver(driver));
	}

	@RequestMapping("/getDriver")
	@ResponseBody
	public Map<String, Object> getDriver(int page, int rows) {
		return driverService.getDriver(page, rows);
	}

	@RequestMapping("/getDriverByNumber")
	@ResponseBody
	public Map<String, Boolean> getDriver(String dNumber) {
		return ResultUtil.getResult(driverService.getDriver(dNumber));
	}

	@RequestMapping("/deleteDriver")
	@ResponseBody
	public Map<String, Boolean> deleteDriver(String ids) {
		return ResultUtil.getResult(driverService.deleteDriver(ids));
	}

	@RequestMapping("/editDriver")
	@ResponseBody
	public Map<String, Boolean> editDriver(Driver driver) {
		return ResultUtil.getResult(driverService.editDriver(driver));
	}

	@RequestMapping("/getDepartureDriver")
	@ResponseBody
	public List<Driver> getDepartureDriver() {
		return driverService.getDepartureDriver();
	}

}
